home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / gepackte_disketten / 1993 / 05_93_2.dms / 05_93_2.adf / boopsi / BOOPSI.c < prev    next >
C/C++ Source or Header  |  1993-04-23  |  4KB  |  146 lines

  1. /*
  2.  * Programm: Boopsi.c
  3.  * Es demonstriert die Kommunikations-
  4.  * möglichkeiten zwischen zwei BOOPSI-Objekten,
  5.  * ohne daß unser Programm die Steuerung übernehmen
  6.  * muß.
  7.  * Compiler: SAS-C
  8.  * Aufruf:   lc -L boopsi.c
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <utility/tagitem.h>
  13. #include <intuition/intuition.h>
  14. #include <intuition/gadgetclass.h>
  15. #include <intuition/icclass.h>
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18.  
  19. struct Library *IntuitionBase;
  20. struct Window  *MyWindow;
  21. struct IntuiMessage *IMsg;
  22. struct Gadget *Prop, *Integer;
  23.  
  24. /*
  25.  * Teilt dem Prop-Gadget mit, sein Attribut
  26.  * PGA_Top in STRINGA_LongVal zu konvertieren
  27.  */
  28. struct TagItem Prop_To_Int[] =
  29. {
  30.   PGA_Top, STRINGA_LongVal,
  31.   TAG_END,0
  32. };
  33.  
  34. /*
  35.  * Teilt dem String-Gadget mit, sein Attribut
  36.  * STRINGA_LongVal in PGA_Top zu konvertieren
  37.  */
  38. struct TagItem Int_To_Prop[] =
  39. {
  40.   STRINGA_LongVal, PGA_Top,
  41.   TAG_END,0
  42. };
  43.  
  44. /* Parameter fürs Öffnen des Fensters */
  45. struct TagItem WindowTags[] =
  46. {
  47.   WA_Flags, WFLG_DEPTHGADGET | WFLG_DRAGBAR |
  48.             WFLG_CLOSEGADGET,
  49.   WA_IDCMP, IDCMP_CLOSEWINDOW,
  50.   WA_Height, 200, WA_Width, 300,
  51.   WA_Title, (ULONG)"BOOSPI-Test",
  52.   TAG_END,0
  53. };
  54.  
  55. void main(void)
  56. {
  57.   BOOL Fertig = FALSE; /* Für die Message-Schleife */
  58.  
  59.   /*
  60.    * Öffnen der Library (mind. V37, also OS 2.0 und
  61.    * höher
  62.    */
  63.   IntuitionBase = OpenLibrary("intuition.library", 37);
  64.  
  65.   if( IntuitionBase )
  66.   {
  67.     MyWindow = OpenWindowTagList(NULL,WindowTags);
  68.  
  69.     if( MyWindow )
  70.     {
  71.       /* Erzeugen eines propgclass-Objekts */
  72.       Prop=(struct Gadget *)NewObject(NULL,"propgclass",
  73.           GA_ID,     1, /* ID-Nummer des Gadgets /*
  74.           GA_Width,  10, /* Gadget-Breite */
  75.           GA_Height, 80, /* Gadget-Höhe   */
  76.           GA_Top,    (MyWindow->BorderTop) + 2,
  77.           GA_Left,   (MyWindow->BorderLeft) + 2,
  78.           /* Zeiger auf die Konvertierungs-Tags */
  79.           ICA_MAP,   Prop_To_Int,
  80.           PGA_Total, 100, /* 100 mögliche Positionen */
  81.           PGA_Top,   10,  /* Startposition */
  82.           PGA_Visible, 10, /* Sichtbare Größe des
  83.                               Gadgetsknopfs */
  84.           PGA_NewLook, TRUE,
  85.           TAG_END);
  86.  
  87.       if( Prop )
  88.       {
  89.         /* Erzeugen eines Integer-String-Objekts */
  90.         Integer=(struct Gadget *)
  91.                          NewObject(NULL,"strgclass",
  92.             GA_ID,2,  /* ID-Nummer des Gadgets */
  93.             GA_Width,  100, /* Gadget-Breite */
  94.             GA_Height, 20,  /* Gadget-Höhe   */
  95.             GA_Top,  (MyWindow->BorderTop) + 5,
  96.             GA_Left, (MyWindow->BorderLeft) + 20,
  97.             ICA_MAP, Int_To_Prop,
  98.  
  99.             /* Das Objekt ist zu benachrichtigen */
  100.             ICA_TARGET, Prop,
  101.  
  102.             /* Vorgänger dieses Gadgets */
  103.             GA_Previous, Prop,
  104.  
  105.             STRINGA_LongVal,  10, /* Startwert */
  106.             STRINGA_MaxChars, 3,  /* Max. Zeichen */
  107.             TAG_END);
  108.  
  109.         if( Integer )
  110.         {
  111.           /* Da während der Initialisierung des   */
  112.           /* Prop-Gadgets das Integer-Gadget noch */
  113.           /* nicht exisitiert, muß das Ziel (ICA_ */
  114.           /* TARGET) jetzt übergeben werden.      */
  115.           SetGadgetAttrs(Prop, MyWindow, NULL,
  116.               ICA_TARGET, Integer, TAG_END);
  117.  
  118.           /* Gadgets ans Fenster anhängen und an- */
  119.           /* zeigen.                              */
  120.           AddGList(MyWindow, Prop, -1, -1, NULL);
  121.           RefreshGList(Prop, MyWindow, NULL, -1);
  122.  
  123.           while (Fertig == FALSE)
  124.           {
  125.             /* Auf die CLOSEWINDOW-Message warten */
  126.             WaitPort(MyWindow->UserPort);
  127.  
  128.             while (IMsg = GetMsg(MyWindow->UserPort))
  129.             {
  130.               if (IMsg->Class == IDCMP_CLOSEWINDOW)
  131.                 Fertig = TRUE;
  132.               ReplyMsg(IMsg);
  133.             }
  134.           }
  135.           RemoveGList(MyWindow, Prop, -1);
  136.           DisposeObject(Integer);
  137.         }
  138.         DisposeObject(Prop);
  139.       }
  140.       CloseWindow(MyWindow);
  141.     }
  142.     CloseLibrary(IntuitionBase);
  143.   }
  144. }
  145.  
  146.